package com.lq.file.filemanager.controller;

import com.lq.file.filemanager.util.FileServiceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @program: file-manager
 * @description:
 * @author: LQ
 * @create: 2021-08-12 18:33
 */
@Controller
@RequestMapping("/pdf")
public class PdfController {
    @Autowired
    FileServiceUtil serviceUtil;

    @ResponseBody
    @RequestMapping("/readFileToBase64")
    public String readFile2Base64( HttpServletRequest request, HttpServletResponse response) {
        try {
            String result = serviceUtil.getFileService().readFileToBase64(request,response, "pdf.pdf","/2021/08/07/");
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            return e.toString();
        }
    }
}
